import java.util.Enumeration;
import java.util.LinkedList;

public class Ray {
	public static final double MAX_T = Double.MAX_VALUE;
    Vector origin;
    Vector direction;
    double t;
    Renderable object;
    int materialIndex;

    public Ray(Vector eye, Vector dir) {
        origin = eye;
        direction = dir;
        t=0;
        object=null;
    }
    
    public Vector getDirection(){
    	return this.direction;
    }
    
    
    public Vector getOrigin(){
    	return this.origin;
    }
    
    public boolean trace(LinkedList<Renderable> objects) {
        
        t = MAX_T;
        object = null;
    
        for(Renderable obj : objects){
        	Renderable object = obj;
        	object.intersect(this);
        }
        return (object != null);
    }
    
    @Override
    public String toString(){
    	return ("Origin: "+origin+", Direction: "+direction);
    }
    
    public void setT(double newT){
    	this.t = newT;
    }
    
    public double getT(){
    	return t;
    }
}
